﻿using System;
using System.Collections.Generic;
using System.Text;
using OpenGameEngine.GameObjects;

namespace OpenGameEngine.Hud
{
    public class HudLayer
        : Object
    {
         #region IDisposable
        private Boolean _disposed=false;

        ~HudLayer()
        {
            if (!_disposed)
            {
                Dispose(false);
                _disposed = true;
            }
        }

        public void Dispose()
        {
            if (!_disposed)
            {
                Dispose(true);
                _disposed = true;
            }
            GC.SuppressFinalize(this);
        }

        protected void Dispose(Boolean disposeManagedResources)
        {
            if (disposeManagedResources)
            {
                if (Labels != null)
                {
                    foreach (HudLabel l in Labels)
                        l.Dispose();

                    Labels = null;
                }
                if (Images != null)
                {
                    foreach (HudImage i in Images)
                        i.Dispose();

                    Images = null;
                }
            }
        }
        #endregion

        public Boolean Visible { get; set; }

        public List<HudLabel> Labels { get; set; }

        public List<HudImage> Images { get; set; }

        public HudLayer()
        {
            Visible = true;
            Labels = new List<HudLabel>();
            Images = new List<HudImage>();
        }

        public GameObject[] GetElements()
        {
            List<GameObject> elements = new List<GameObject>();
            elements.AddRange(Labels.ToArray());
            elements.AddRange(Images.ToArray());
            return elements.ToArray();
        }
    }
}
